package com.woniuxy.house.service.serviceimpl;

import com.woniuxy.house.entity.Search;
import com.woniuxy.house.entity.Source;
import com.woniuxy.house.mapper.SearchMapper;
import com.woniuxy.house.mapper.SourceMapper;
import com.woniuxy.house.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SearchServiceImp implements SearchService {
    @Autowired
    private SourceMapper sourceMapper;
    @Autowired
    private SearchMapper searchMapper;

    @Override
    public List<Source> getBySearchText(String searchText) {
        Source source=new Source();
        source.setTitle(searchText);

        return sourceMapper.getSourceListByCondition(source);

    }

    @Override
    public List<Search> getByUserId(Integer userId) {


        return searchMapper.getByUserId(userId);
    }

    @Override
    public List<Search> getHottestSearchLimitSize(Integer size) {
        return   searchMapper.getHottestSearch(size);


    }

    @Override
    public void addSearch(Search search) {
        searchMapper.add(search);
    }
}
